﻿namespace Compass.Wpf.ViewModels.Settings;

public class SettingsViewModel : NavigationViewModel
{
    #region ctor-设置界面
    public SettingsViewModel(IContainerProvider provider) : base(provider)
    {
        CreateMenuBar();
        NavigateCommand = new DelegateCommand<MenuBar>(Navigate);
    }
    public DelegateCommand<MenuBar> NavigateCommand { get; }
    #endregion

    #region 属性

    public ObservableRangeCollection<MenuBar> MenuBars { get; } = new();
    #endregion

    #region 导航

    private void Navigate(MenuBar? obj)
    {
        if (obj == null || string.IsNullOrWhiteSpace(obj.NameSpace)) return;
        RegionManager.Regions[PrismManager.SettingsViewRegionName].RequestNavigate(obj.NameSpace,
            back => { Journal = back.Context.NavigationService.Journal; });
    }
    #endregion

    #region 初始化
    /// <summary>
    /// 初始化菜单集合
    /// </summary>
    void CreateMenuBar()
    {
        MenuBars.Add(new MenuBar { Icon = "BarcodeScan", Title = "设计物料", NameSpace = "MaterialItemsView" });
        MenuBars.Add(new MenuBar { Icon = "FormatListNumberedRtl", Title = "下料清单", NameSpace = "AccCutListView" });
        MenuBars.Add(new MenuBar { Icon = "Qrcode", Title = "仓库物料", NameSpace = "CargoesView" });
        MenuBars.Add(new MenuBar { Icon = "Warehouse", Title = "库位设置", NameSpace = "LocationsView" });
        MenuBars.Add(new MenuBar { Icon = "Storefront", Title = "供应商", NameSpace = "VendorsView" });
        MenuBars.Add(new MenuBar { Icon = "Cog", Title = "系统设置", NameSpace = "" });
        MenuBars.Add(new MenuBar { Icon = "Information", Title = "关于更多", NameSpace = "AboutView" });
    }
    #endregion
    //public override async void OnNavigatedTo(NavigationContext navigationContext)
    //{
    //    base.OnNavigatedTo(navigationContext);
    //    await Task.Delay(100);
    //    Navigate(MenuBars.Last());
    //}
}